home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / LispExample / LispListener.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  70 lines

  1. /*
  2. **    LispListener.m
  3. **    A Scrollable LispText.
  4. **    Lee Boynton, NeXT, Inc., 1989
  5. */
  6.  
  7. #import "Lisp.h"
  8. #import "LispText.h"
  9. #import "LispListener.h"
  10. #import <appkit/Application.h>
  11. #import <defaults/defaults.h>
  12. #import <stdlib.h>
  13.  
  14. @implementation LispListener
  15.  
  16. + newFrame:(NXRect *)theFrame
  17. {
  18.     id scroll, text;
  19.     float ascender, descender, lineHeight;
  20.     id font;
  21.     NXSize maxSize;
  22.     const char *imageName = NXGetDefaultValue([NXApp appName],"LispImage");
  23.     char initialText[1024];
  24.     sprintf(initialText,"Waiting for %s to launch...",imageName);
  25.     maxSize.width = 1.0e30;
  26.     maxSize.height = 1.0e30;
  27.     font = [Text getDefaultFont];
  28.     text = [LispText newFrame:NULL text:initialText alignment:NX_LEFTALIGNED];
  29.     NXTextFontInfo(font, &ascender, &descender, &lineHeight);
  30.     [text sizeTo:0.:lineHeight];
  31.     [text moveTo:0.:0.];
  32.     [text setMaxSize:&maxSize];
  33.     [text setVertResizable:YES];
  34.     [text setOverstrikeDiacriticals:NO];
  35.     [text setAutoresizeSubviews:YES];
  36.     [text setAutosizing:NX_WIDTHSIZABLE];
  37.     scroll = [super newFrame:NULL];
  38.     [scroll setVertScrollerRequired:YES];
  39.     [scroll setDynamicScrolling:YES];
  40.     [scroll setDocView:text];
  41.     [scroll setBackgroundGray:NX_WHITE];
  42.     [scroll setAutoresizeSubviews:YES];
  43.     [scroll setAutosizing:NX_WIDTHSIZABLE|NX_HEIGHTSIZABLE];
  44.     [scroll setBorderType:NX_NOBORDER];
  45.     [[text superview] setAutoresizeSubviews:YES];
  46.     [scroll moveTo:NX_X(theFrame):NX_Y(theFrame)];
  47.     [scroll sizeTo:NX_WIDTH(theFrame):NX_HEIGHT(theFrame)];
  48.     self = scroll;
  49.     theText = text;
  50.     [theText setDelegate:self];
  51.     return scroll;
  52. }
  53.  
  54. - evaluate:(const char *)theString;
  55. {
  56.     [theText inputLisp:theString];
  57.     return self;
  58. }
  59.  
  60.  
  61. @end
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.